// http://api.douban.com/v2/user/1000001

const rp = require('request-promise-native')

async function fetchMovie (item) {
    const url = `http://api.douban.com/v2/movie/subject/${item.doubanId}`
    const res = await rp(url)

    return res
}

;(async ()=> {
    let movies = [{ doubanId: 27036735,
        title: '使女的故事 第二季',
        rate: '9.5',
        poster: 'https://img3.doubanio.com/view/photo/l_ratio_poster/public/p2518829313.jpg' },
      { doubanId: 24773958,
        title: '复仇者联盟3：无限战争',
        rate: '8.6',
        poster: 'https://img3.doubanio.com/view/photo/l_ratio_poster/public/p2517753454.jpg' }]

    movies.map(async movie => {
        let movieData = await fetchMovie(movie)

        try {
            movieData = JSON.parse(movieData)
            console.log(movieData.tags)
            console.log(movieData.summary)
        } catch (err) {
            console.log(err)
        }
        console.log(movieData)
    })
})()